﻿/*
 * @author: wizardc
 */

using Dou.UI;
using UnityEditor;
using UnityEngine;
using TextEditor = UnityEditor.UI.TextEditor;

namespace DouEditor.UI
{
    [CustomEditor(typeof(DText), true)]
    [CanEditMultipleObjects]
    public class DTextEditor : TextEditor
    {
        [MenuItem("GameObject/DouUI/Text - Legacy", false, 10)]
        private static void CreateUI(MenuCommand menuCommand)
        {
            var go = UIEditorUtil.CreateUIElement("Text (Legacy)");
            var text = go.AddComponent<DText>();
            text.text = "New Text";
            text.supportRichText = false;
            text.raycastTarget = false;
            UIEditorUtil.PlaceUIElementRoot(go, menuCommand);
        }

        public override void OnInspectorGUI()
        {
            var text = (DText) target;
            using (new GUILayout.VerticalScope())
            {
                text.useGray = EditorGUILayout.Toggle(new GUIContent("置灰"), text.useGray);
            }
            base.OnInspectorGUI();
        }
    }
}
